package edu.pku.sei.modeler.uml.commands.sequence;

import edu.pku.sei.modeler.model.core.MetaModelElement;
import edu.pku.sei.modeler.model.structure.MetaNode;
import edu.pku.sei.modeler.model.uml.BasicInteractions.Lifeline;
import edu.pku.sei.modeler.uml.commands.NestedElementDeleteCommand;

public class UMLStateInvariantDeleteCommand extends NestedElementDeleteCommand {

	public UMLStateInvariantDeleteCommand(MetaNode node, MetaNode fatherNode,
			boolean isDeletedFromDiagram) {
		super(node, fatherNode, isDeletedFromDiagram);
	}

	@Override
	protected void deleteModelElement() {
		Lifeline lifeline = (Lifeline) fatherNode.getModelElement();
		lifeline.getIncludedStateInvariants().remove(
				this.node.getModelElement());
	}

	@Override
	protected void undoDeleteModelElement() {
		MetaModelElement modelElement = this.node.getModelElement();
		Lifeline lifeline = (Lifeline) fatherNode.getModelElement();
		lifeline.getIncludedStateInvariants().add(modelElement);
	}

}
